package com.test;

public class SimpleWN {

	public static Object object = new Object();

	public static class T1 extends Thread {

		@Override
		public void run() {
			synchronized (object) {
				try {
					System.out.println(System.currentTimeMillis() + " :T1 start");
					System.out.println("T1 wait for object");
					object.wait();
					System.out.println(System.currentTimeMillis() + " :T1 end");
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}

	}

	public static class T2 extends Thread {

		@Override
		public void run() {

			synchronized (object) {
				System.out.println(System.currentTimeMillis() + " :T2 startm notify one thread");
				object.notify();
				try {
					Thread.sleep(2000);
					System.out.println(System.currentTimeMillis() + " :T2 end");
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}

	}

	public static void main(String[] args) throws InterruptedException {
		T1 t1 = new T1();
		T2 t2 = new T2();
		t1.start();
		t2.start();
		t1.join();
	}
}
